package com.cnzha.mr.sort;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @Author: zhaoxin
 * @email: zdkk@foxmail.com
 * @Date: 2020/4/4 18:14
 */
public class PhontParation extends Partitioner<FlowBean, Text> {

    @Override
    public int getPartition(FlowBean flowBean, Text text, int numPartitions) {
        String phone = text.toString();
        if (phone.startsWith("136")) {
            return 0;
        } else if (phone.startsWith("131")) {
            return 1;
        } else if (phone.startsWith("138")) {
            return 2;
        } else if (phone.startsWith("139")) {
            return 3;
        }
        return 4;
    }
}
